#!/usr/bin/env python3

'''
https://github.com/cirosantilli/linux-kernel-module-cheat#release-zip
'''

import os
import subprocess
import zipfile

import common

def main():
    os.makedirs(kwargs['release_dir'], exist_ok=True)
    if os.path.exists(kwargs['release_zip_file']):
        os.unlink(kwargs['release_zip_file'])
    zipf = zipfile.ZipFile(kwargs['release_zip_file'], 'w', zipfile.ZIP_DEFLATED)
    for arch in kwargs['all_archs']:
        self.setup(common.get_argparse(default_args={'arch': arch}))
        zipf.write(kwargs['qcow2_file'], arcname=os.path.relpath(kwargs['qcow2_file'], kwargs['root_dir']))
        zipf.write(kwargs['linux_image'], arcname=os.path.relpath(kwargs['linux_image'], kwargs['root_dir']))
    zipf.close()

if __name__ == '__main__':
    main()
